#include<iostream>
#include<cstring>
using namespace std;

string num;
bool del[240];

int main() {
    int count;
    while(scanf("%s", &num) != EOF) {
        // string str = num;
        cin >> count;
        memset(del, false, sizeof(del));

//      特例处理
        if (count >= num.length()) {
            cout << -1 << endl;
            break;
        } else if (count == num.length()-1) {
            cout << "" <<endl;
            break;
        }

//      删数核心
        while(count--) {
            for (int i=0; i<num.length(); i++) {
                if (i == num.length()-1 || num[i] > num[i+1]) {
                    num.erase(i);
                    break;
                }
            }
        }

//      输出
        while(num[0] == '0')
            num.erase(0);
        for(int i=0; i<num.length(); i++) {
            cout << num[i];
        }
        cout << endl;
    }
    return 0;
}